﻿using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.ChaXunGL
{
    public partial class WebForm1 : BasePage
    {
        #region 属性

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtGrid
        {
            get
            {
                return ViewState["dtGrid"] as DataTable;
            }
            set
            {
                ViewState["dtGrid"] = value;
            }
        }


        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        /// <summary>
        /// 行政区
        /// </summary>
        QS_JX_XINGZHENGQBLL XZQ = new QS_JX_XINGZHENGQBLL();


        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            ScriptManager1.RegisterPostBackControl(btnExport);
            this.gvYongHuXX.DataSource = this.dtGrid;
            this.gvYongHuXX.DataBind();

        }




        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            if (txtShuiLiangYM.Text != "")
            {
                LoadGridData();
              
            }
        }




        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {

            gvYongHuXX.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //水量年月
            // string water_y_m = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();
            txtShuiLiangYM.Text = "2017";
           


        }



        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridData()
        {

            DataTable dt = new DataTable();
            string[] arr = { "0341500024", "若安混凝土", "10073", "7587.0000", "2017-11-20" };
            dt.Columns.Add("BH");
            dt.Columns.Add("MC");
            dt.Columns.Add("ID");
            dt.Columns.Add("SJ");
            dt.Columns.Add("RQ");
            for (int i = 0; i < 10; i++)
            {
                DataRow dr = dt.NewRow();
                dr["BH"] = arr[0];
                dr["MC"] = arr[1];
                dr["ID"] = arr[2];
                dr["SJ"] = arr[3];
                dr["RQ"] = arr[4];
                dt.Rows.Add(dr);
            }

            gvYongHuXX.DataSource = dt;
            gvYongHuXX.DataBind();
            if (this.dtGrid != null && this.dtGrid.Rows.Count > 0)
            {
                zjl.Text = "共" + this.dtGrid.Rows.Count.ToString() + "条";
                gvYongHuXX.FocusedRowIndex = 0;
                
            }

        }

       

        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
       
        #endregion

        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width)
        {
            GridViewDataTextColumn c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            gv.Columns.Add(c);
        }

        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width, string format)
        {
            GridViewDataTextColumn c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            c.PropertiesEdit.DisplayFormatString = format;
            gv.Columns.Add(c);
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            string sName = txtShuiLiangYM.Text + "用户信息";
            ASPxGridViewExporter1.WriteXlsToResponse(sName);

        }
    }
}